// Made with Amplify Shader Editor v1.9.3.3
// Available at the Unity Asset Store - http://u3d.as/y3X 
Shader "RK_RF_Fog_V3"
{
    Properties
    {
//        [MainTexture] _BaseMap("Albedo", 2D) = "white" {}
        [HideInInspector] _AlphaCutoff("Alpha Cutoff ", Range(0, 1)) = 0.5
        [HideInInspector] _EmissionColor("Emission Color", Color) = (1,1,1,1)
        _MainTex("MainTex", 2D) = "white" {}
        [HideInInspector] _texcoord( "", 2D ) = "white" {}

    }

    SubShader
    {
		LOD 0

		

        Tags { "RenderPipeline"="UniversalPipeline" "RenderType"="Transparent" "Queue"="Transparent" }

        Cull Back
        AlphaToMask Off
 

        
        Pass
        {
            
			Name "Forward"
			Tags { "LightMode"="UniversalForward" }

			Blend SrcAlpha OneMinusSrcAlpha, One OneMinusSrcAlpha
            ZWrite Off
            ZTest LEqual
//            Offset 0 , 0
            ColorMask RGBA
            

            HLSLPROGRAM
            #define _RECEIVE_SHADOWS_OFF 1
            #define ASE_SRP_VERSION 100900
            #define ASE_USING_SAMPLING_MACROS 1

            // #pragma prefer_hlslcc gles
            // 

            #pragma vertex vert
            #pragma fragment frag
            #pragma target 4.5
            
			#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
			#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
			#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/UnityInstancing.hlsl"
			#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"

            #if ASE_SRP_VERSION <= 70108
            #define REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR
            #endif

            

            struct VertexInput
            {
                float4 vertex : POSITION;
                float3 ase_normal : NORMAL;
                float4 ase_texcoord : TEXCOORD0;
                UNITY_VERTEX_INPUT_INSTANCE_ID
            };

            struct VertexOutput
            {
                float4 clipPos : SV_POSITION;
                float3 worldPos : TEXCOORD0;
                #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
				float4 shadowCoord : TEXCOORD1;
                #endif
                #ifdef ASE_FOG
				float fogFactor : TEXCOORD2;
                #endif
                float4 ase_texcoord3 : TEXCOORD3;
                UNITY_VERTEX_INPUT_INSTANCE_ID
                UNITY_VERTEX_OUTPUT_STEREO
            };

            CBUFFER_START(UnityPerMaterial)
            float4 _FogTex_ST;
            float4 _MainTex_ST;
            float4 _FogMask_ST;
            CBUFFER_END
            TEXTURE2D(_FogTex);
            SAMPLER(sampler_FogTex);
            TEXTURE2D(_MainTex);
            SAMPLER(sampler_MainTex);
            TEXTURE2D(_FogMask);
            SAMPLER(sampler_FogMask);


            
            VertexOutput vert(VertexInput v )
            {
                VertexOutput o = (VertexOutput)0;
                UNITY_SETUP_INSTANCE_ID(v);
                UNITY_TRANSFER_INSTANCE_ID(v, o);
                UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);

                o.ase_texcoord3.xy = v.ase_texcoord.xy;
                
                //setting value to unused interpolator channels and avoid initialization warnings
                o.ase_texcoord3.zw = 0;
                #ifdef ASE_ABSOLUTE_VERTEX_POS
					float3 defaultVertexValue = v.vertex.xyz;
                #else
                float3 defaultVertexValue = float3(0, 0, 0);
                #endif
                float3 vertexValue = defaultVertexValue;
                #ifdef ASE_ABSOLUTE_VERTEX_POS
					v.vertex.xyz = vertexValue;
                #else
                v.vertex.xyz += vertexValue;
                #endif

                float3 positionWS = TransformObjectToWorld(v.vertex.xyz);
                float4 positionCS = TransformWorldToHClip(positionWS);

                o.worldPos = positionWS;
            	
    //             #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
				// VertexPositionInputs vertexInput = (VertexPositionInputs)0;
				// vertexInput.positionWS = positionWS;
				// vertexInput.positionCS = positionCS;
				// o.shadowCoord = GetShadowCoord( vertexInput );
    //             #endif
                #ifdef ASE_FOG
				o.fogFactor = ComputeFogFactor( positionCS.z );
                #endif
                // o.clipPos = positionCS;
				o.clipPos = positionCS ;
                return o;
            }



            half4 frag(VertexOutput IN ) : SV_Target
            {
                UNITY_SETUP_INSTANCE_ID(IN);
                UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(IN);

                // #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
                
                float3 WorldPosition = IN.worldPos;
                // #endif
                
                float4 ShadowCoords = float4(0, 0, 0, 0);

                #if defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
                #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
						ShadowCoords = IN.shadowCoord;
                #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
						ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
                #endif
                #endif
                float2 uv_FogTex = IN.ase_texcoord3.xy * _FogTex_ST.xy + _FogTex_ST.zw;
                float4 fogTex661 = SAMPLE_TEXTURE2D( _FogTex, sampler_FogTex, uv_FogTex );
                float2 uv_MainTex = IN.ase_texcoord3.xy * _MainTex_ST.xy + _MainTex_ST.zw;
                float4 screenImage552 = SAMPLE_TEXTURE2D( _MainTex, sampler_MainTex, uv_MainTex );
                float2 uv_FogMask = IN.ase_texcoord3.xy * _FogMask_ST.xy + _FogMask_ST.zw;
                float fogMask662 = SAMPLE_TEXTURE2D( _FogMask, sampler_FogMask, uv_FogMask ).r;
                float4 lerpResult658 = lerp( float4( (fogTex661).rgb , 0.0 ) , screenImage552 , fogMask662);
                float4 appendResult660 = (float4(lerpResult658.rgb , ( 1.0 - ( step( 1.0 , fogTex661.a ) * ( 1.0 - fogMask662 ) ) )));
                
                float4 Color = appendResult660;

                #ifdef _ALPHATEST_ON
					clip( Alpha - AlphaClipThreshold );
                #endif

                #ifdef LOD_FADE_CROSSFADE
					LODDitheringTransition( IN.clipPos.xyz, unity_LODFade.x );
                #endif

                #ifdef ASE_FOG
					Color = MixFog( Color, IN.fogFactor );
                #endif

            	return Color;
            }
            ENDHLSL
        }

        
        Pass
        {
            
            Name "DepthOnly"
            Tags { "LightMode"="DepthOnly" }

            ZWrite On
            ColorMask 0
            AlphaToMask Off

            HLSLPROGRAM
            #define _RECEIVE_SHADOWS_OFF 1
            #define ASE_SRP_VERSION 100900
            #define ASE_USING_SAMPLING_MACROS 1

            #pragma prefer_hlslcc gles
            

            #pragma vertex vert
            #pragma fragment frag

            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl"
            #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"

            

            struct VertexInput
            {
                float4 vertex : POSITION;
                float3 ase_normal : NORMAL;
                
                UNITY_VERTEX_INPUT_INSTANCE_ID
            };

            struct VertexOutput
            {
                float4 clipPos : SV_POSITION;
                // #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
                float3 worldPos : TEXCOORD0;
                // #endif
                #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
				float4 shadowCoord : TEXCOORD1;
                #endif
                
                UNITY_VERTEX_INPUT_INSTANCE_ID
                UNITY_VERTEX_OUTPUT_STEREO
            };

            CBUFFER_START(UnityPerMaterial)

            float4 _FogTex_ST;
            float4 _MainTex_ST;
            float4 _FogMask_ST;
            CBUFFER_END
            

            
            VertexOutput vert(VertexInput v )
            {
                VertexOutput o = (VertexOutput)0;
                UNITY_SETUP_INSTANCE_ID(v);
                UNITY_TRANSFER_INSTANCE_ID(v, o);
                UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);

                
                #ifdef ASE_ABSOLUTE_VERTEX_POS
					float3 defaultVertexValue = v.vertex.xyz;
                #else
                float3 defaultVertexValue = float3(0, 0, 0);
                #endif
                float3 vertexValue = defaultVertexValue;
                #ifdef ASE_ABSOLUTE_VERTEX_POS
					v.vertex.xyz = vertexValue;
                #else
                v.vertex.xyz += vertexValue;
                #endif

                v.ase_normal = v.ase_normal;

                float3 positionWS = TransformObjectToWorld(v.vertex.xyz);

                // #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
                o.worldPos = positionWS;
                // #endif

                o.clipPos = TransformWorldToHClip(positionWS);
                #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR) && defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
					VertexPositionInputs vertexInput = (VertexPositionInputs)0;
					vertexInput.positionWS = positionWS;
					vertexInput.positionCS = clipPos;
					o.shadowCoord = GetShadowCoord( vertexInput );
                #endif
                return o;
            }

  

            half4 frag(VertexOutput IN ) : SV_TARGET
            {
                UNITY_SETUP_INSTANCE_ID(IN);
                UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(IN);

                // #if defined(ASE_NEEDS_FRAG_WORLD_POSITION)
                
                float3 WorldPosition = IN.worldPos;
                // #endif
                
                float4 ShadowCoords = float4(0, 0, 0, 0);

                #if defined(ASE_NEEDS_FRAG_SHADOWCOORDS)
                #if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
						ShadowCoords = IN.shadowCoord;
                #elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
						ShadowCoords = TransformWorldToShadowCoord( WorldPosition );
                #endif
                #endif

                
                float Alpha = 1;
                float AlphaClipThreshold = 0.5;

                #ifdef _ALPHATEST_ON
					clip(Alpha - AlphaClipThreshold);
                #endif

                #ifdef LOD_FADE_CROSSFADE
					LODDitheringTransition( IN.clipPos.xyz, unity_LODFade.x );
                #endif
                return 0;
            }
            ENDHLSL
        }

        
    }
    CustomEditor "UnityEditor.ShaderGraph.PBRMasterGUI"
    Fallback "Hidden/InternalErrorShader"
	
}/*ASEBEGIN
Version=19303
Node;AmplifyShaderEditor.CommentaryNode;675;5671.661,2166.461;Inherit;False;229;161;;1;667;1是未解锁 包含外界;1,1,1,1;0;0
Node;AmplifyShaderEditor.CommentaryNode;666;5366.521,2175.93;Inherit;False;245;165.9999;;1;664;1是解锁区域;1,1,1,1;0;0
Node;AmplifyShaderEditor.CommentaryNode;676;5782.135,1372.674;Inherit;False;229;161;;1;673;1是未解锁 包含外界;1,1,1,1;0;0
Node;AmplifyShaderEditor.LerpOp;658;5777.152,1734.032;Inherit;False;3;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;2;FLOAT;0;False;1;COLOR;0
Node;AmplifyShaderEditor.GetLocalVarNode;663;5134.475,1572.177;Inherit;False;661;fogTex;1;0;OBJECT;;False;1;COLOR;0
Node;AmplifyShaderEditor.BreakToComponentsNode;670;5577.135,1374.674;Inherit;False;COLOR;1;0;COLOR;0,0,0,0;False;16;FLOAT;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4;FLOAT;5;FLOAT;6;FLOAT;7;FLOAT;8;FLOAT;9;FLOAT;10;FLOAT;11;FLOAT;12;FLOAT;13;FLOAT;14;FLOAT;15
Node;AmplifyShaderEditor.SwizzleNode;669;5396.135,1627.674;Inherit;False;FLOAT3;0;1;2;3;1;0;COLOR;0,0,0,0;False;1;FLOAT3;0
Node;AmplifyShaderEditor.OneMinusNode;667;5721.661,2216.461;Inherit;False;1;0;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.StepOpNode;673;5836.135,1422.674;Inherit;False;2;0;FLOAT;1;False;1;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.OneMinusNode;677;6340.135,2069.674;Inherit;False;1;0;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;674;6198.135,2047.674;Inherit;False;2;2;0;FLOAT;0;False;1;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.DynamicAppendNode;660;6476.537,1692.456;Inherit;False;FLOAT4;4;0;FLOAT3;0,0,0;False;1;FLOAT;0;False;2;FLOAT;0;False;3;FLOAT;1;False;1;FLOAT4;0
Node;AmplifyShaderEditor.GetLocalVarNode;570;5136,1728;Inherit;False;552;screenImage;1;0;OBJECT;;False;1;COLOR;0
Node;AmplifyShaderEditor.GetLocalVarNode;664;5416.521,2225.93;Inherit;False;662;fogMask;1;0;OBJECT;;False;1;FLOAT;0
Node;AmplifyShaderEditor.RegisterLocalVarNode;552;4816,1408;Inherit;False;screenImage;-1;True;1;0;COLOR;0,0,0,0;False;1;COLOR;0
Node;AmplifyShaderEditor.SamplerNode;66;4368,1408;Inherit;True;Property;_MainTex;MainTex;0;0;Create;True;0;0;0;False;0;False;-1;None;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
Node;AmplifyShaderEditor.SamplerNode;481;4384,2000;Inherit;True;Global;_FogMask;FogMask;2;0;Create;True;0;0;0;False;0;False;-1;None;;True;0;False;black;Auto;False;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
Node;AmplifyShaderEditor.RegisterLocalVarNode;662;4736,2016;Inherit;False;fogMask;-1;True;1;0;FLOAT;0;False;1;FLOAT;0
Node;AmplifyShaderEditor.SamplerNode;480;4400,1712;Inherit;True;Global;_FogTex;_FogTex;1;0;Create;True;0;0;0;False;0;False;-1;None;;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
Node;AmplifyShaderEditor.RegisterLocalVarNode;661;4736,1776;Inherit;False;fogTex;-1;True;1;0;COLOR;0,0,0,0;False;1;COLOR;0
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;462;3971.557,-92.66322;Float;False;False;-1;2;UnityEditor.ShaderGraph.PBRMasterGUI;0;31;New Amplify Shader;5d29ac6054595c941a4f6c2b59ab8567;True;ShadowCaster;0;2;ShadowCaster;1;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;True;0;False;;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;3;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;False;False;0;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;False;False;True;False;False;False;False;0;False;;False;False;False;False;False;False;False;False;False;True;1;False;;True;3;False;;False;True;1;LightMode=ShadowCaster;True;5;True;12;all;0;Hidden/InternalErrorShader;0;0;Standard;0;False;0
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;463;3971.557,-92.66322;Float;False;False;-1;2;UnityEditor.ShaderGraph.PBRMasterGUI;0;31;New Amplify Shader;5d29ac6054595c941a4f6c2b59ab8567;True;DepthOnly;0;3;DepthOnly;3;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;True;0;False;;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;3;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;False;False;0;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;False;False;True;False;False;False;False;0;False;;False;False;False;False;False;False;False;False;False;True;1;False;;False;False;True;1;LightMode=DepthOnly;False;True;12;all;0;Hidden/InternalErrorShader;0;0;Standard;0;False;0
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;460;6841.77,1648.69;Float;False;True;-1;2;UnityEditor.ShaderGraph.PBRMasterGUI;0;37;RK_RF_Fog_V3;5d29ac6054595c941a4f6c2b59ab8567;True;Forward;0;0;Forward;3;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;True;0;False;;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;3;RenderPipeline=UniversalPipeline;RenderType=Transparent=RenderType;Queue=Transparent=Queue=0;False;False;0;False;True;2;5;False;;10;False;;1;1;False;;10;False;;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;True;True;True;True;0;False;;False;False;False;False;False;False;False;True;False;0;False;;255;False;;255;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;False;True;2;False;;True;3;False;;True;True;0;False;;0;False;;True;1;LightMode=UniversalForward;True;5;True;12;all;0;Hidden/InternalErrorShader;0;0;Standard;11;Surface;1;638129058534996948;  Blend;0;0;Two Sided;1;0;Cast Shadows;0;0;  Use Shadow Threshold;0;0;Receive Shadows;0;0;GPU Instancing;0;0;Built-in Fog;0;0;Custom Pass;0;0;Meta Pass;0;0;Vertex Position,InvertActionOnDeselection;1;0;0;4;True;False;False;True;False;;True;0
Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;461;5664.816,444.2086;Float;False;False;-1;2;UnityEditor.ShaderGraph.PBRMasterGUI;0;31;New Amplify Shader;5d29ac6054595c941a4f6c2b59ab8567;True;CustomPass;0;1;CustomPass;2;False;False;False;False;False;False;False;False;False;False;False;False;True;0;False;;False;True;0;False;;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;3;RenderPipeline=UniversalPipeline;RenderType=Opaque=RenderType;Queue=Geometry=Queue=0;False;False;0;False;True;0;1;False;;0;False;;0;1;False;;0;False;;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;1;False;;True;3;False;;False;True;1;LightMode=Custom;False;False;0;Hidden/InternalErrorShader;0;0;Standard;0;False;0
WireConnection;658;0;669;0
WireConnection;658;1;570;0
WireConnection;658;2;664;0
WireConnection;670;0;663;0
WireConnection;669;0;663;0
WireConnection;667;0;664;0
WireConnection;673;1;670;3
WireConnection;677;0;674;0
WireConnection;674;0;673;0
WireConnection;674;1;667;0
WireConnection;660;0;658;0
WireConnection;660;3;677;0
WireConnection;552;0;66;0
WireConnection;662;0;481;1
WireConnection;661;0;480;0
WireConnection;460;0;660;0
ASEEND*/
//CHKSM=28E468619DDEB6F5DDFEE0CCACC8557418D0A2FA